Strict

Import mojo
Import agfx


Class TFpsGraph

	Field values_U:Int[]
	Field values_R:Int[]
	Field TIME_GRAPH_LENGTH:Int 
	Field id:Int
	
	Method New()
		Self.TIME_GRAPH_LENGTH = 320
		Self.values_U = New Int[TIME_GRAPH_LENGTH]
		Self.values_R = New Int[TIME_GRAPH_LENGTH]
		Self.id = 0
	End Method
	
	Method Update:Void()
		Self.values_U[Self.id] = Int(AppSpeed()*100)
		Self.values_R[Self.id] = Int(FPS())
		Self.id+=1
		If Self.id>TIME_GRAPH_LENGTH-1 Then Self.id = 0
	End Method

	Method Render:Void()
		SetAlpha 0.25
		SetColor(0,0,0)
		DrawRect(0,DeviceHeight()-(32+200),TIME_GRAPH_LENGTH,200)
		SetAlpha 1.0
		
		For Local i:Int=0 To TIME_GRAPH_LENGTH-1
			SetColor(255,255,0)			
			DrawRect(i,DeviceHeight()-(32+Self.values_U[i]),1,2)
			'DrawCircle(i,DeviceHeight()-Self.values_U[i],2)
			SetColor(0,255,0)
			DrawRect(i,DeviceHeight()-(32+Self.values_R[i]),1,2)
			'DrawCircle(i,DeviceHeight()-Self.values_R[i],2)
		Next 
		
		SetColor(255,0,0)
		DrawLine(Self.id,DeviceHeight()-(32+200),Self.id,DeviceHeight()-(32))
		SetColor(255,255,255)
	End Method

End Class